package com.example.mobile2021606159yhf0412;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class p6 extends AppCompatActivity {

    private EditText edtTxtMaina;
    private Button btnMainJisuan;
    private TextView tvMainResult;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.p6);
        initView();
    }

    private void initView() {
        edtTxtMaina = (EditText) findViewById(R.id.edtTxtMaina);
        btnMainJisuan = (Button) findViewById(R.id.btnMainJisuan);
        tvMainResult = (TextView) findViewById(R.id.tvMainResult);
    }

    public void pingdingonClick(View view) {
        String a = edtTxtMaina.getText().toString();
        if (a.length() == 0) {
            Toast.makeText(p6.this, "请输入分数", Toast.LENGTH_SHORT).show();
        } else {
            double b = Double.parseDouble(a);
            if (b >= 90) {
                tvMainResult.setText("A");
            } else if (80 <= b && b <= 89) {
                tvMainResult.setText("B");
            } else if (70 <= b && b <= 79) {
                tvMainResult.setText("C");
            } else if (60 <= b && b <= 69) {
                tvMainResult.setText("D");
            } else if (b < 60) {
                tvMainResult.setText("E");
            }
        }
    }
}
